//
//  YYJLGraphicDetailController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/10.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLGraphicDetailController.h"
#import "YYJLTestController.h"
@interface YYJLGraphicDetailController ()
{
    UIView  * blureyView;//覆盖层
    UIImageView  * tipView;//提示框
    UIScrollView * _scrollview;
    UILabel      * title;//题目
    UILabel      * style;//类型
    UILabel      * time;//时间
    
}
@end

@implementation YYJLGraphicDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setTitleView:@"图文详情"];
    [self setBackItem];
    
    [self creatUI];
    
    [self addBottomBtn];
    
    blureyView=[[UIView alloc]initWithFrame:self.view.bounds];
    blureyView.backgroundColor=[UIColorFromHex(0x000000) colorWithAlphaComponent:.4];
    [self.view addSubview:blureyView];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
    
    [self addTipView];
   // [self addATtentionview];
}
-(void)creatUI{
    _scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(12*PER_WIDTH, 64, SCREEN_WIDTH-24*PER_WIDTH, SCREEN_HEIGHT-64-66*PER_HEIGHT)];
    _scrollview.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_scrollview];
    
    title=[MyControl createLabelWithFrame:CGRectMake(10*PER_WIDTH, 14*PER_HEIGHT, _scrollview.width-20*PER_WIDTH, 15*PER_HEIGHT) Font:15 Text:@"如何鉴定金银首饰的真伪" Color:BLACK_COLOR];
    [_scrollview addSubview:title];
    
    style=[MyControl createLabelWithFrame:CGRectMake(title.left, title.bottom+15*PER_HEIGHT, 200, 12*PER_HEIGHT) Font:12 Text:@"类型:珠宝知识大全" Color:FEELT_COLOR];
    [_scrollview addSubview:style];
    
    CGFloat width = _scrollview.width-20*PER_WIDTH-style.width;
    time=[MyControl createLabelWithFrame:CGRectMake(_scrollview.width-10*PER_WIDTH-width, style.top, width, 12*PER_HEIGHT) Font:12 Text:@"更新时间: 2016-12-12" Color:FEELT_COLOR];
    time.textAlignment=NSTextAlignmentRight;
    [_scrollview addSubview:time];
    
    
}

#pragma mark--提示view
-(void)addATtentionview{
    UILabel * lab =[MyControl createLabelWithFrame:CGRectMake(0, 28, SCREEN_WIDTH, 36) Font:14 Text:@"恭喜您,使用时长超30分钟,获得5积分" Color:WHITE_COLOR];
    lab.backgroundColor=[UIColorFromHex(0x000000) colorWithAlphaComponent:.7];
    lab.textAlignment=NSTextAlignmentCenter;
    lab.layer.cornerRadius=10;
    [self.view addSubview:lab];
}
#pragma mark--底部按钮
-(void)addBottomBtn{
    UIButton * bottomBtn=[MyControl createButtonWithFrame:CGRectMake(126*PER_WIDTH, SCREEN_HEIGHT-56*PER_HEIGHT, 120*PER_WIDTH, 36*PER_HEIGHT) ImageName:@"" Target:self Action:@selector(test) Title:@"课后小测"];
    bottomBtn .layer.cornerRadius=bottomBtn.height/2;
    bottomBtn.titleLabel.font=[UIFont systemFontOfSize:16*PER_WIDTH];
    [bottomBtn setTitleColor:WHITE_COLOR forState:0];
    bottomBtn.backgroundColor=TINK_COLOR;
    [self.view addSubview:bottomBtn];
}
-(void)test{
    YYJLTestController * test=[[YYJLTestController alloc]init];
    test.testType=AfterTest;
    [self.navigationController pushViewController:test animated:YES];
}

#pragma mark--提示框
-(void)addTipView{
    
    blureyView.hidden=NO;
    [self.view bringSubviewToFront:blureyView];
    tipView =[[UIImageView alloc]initWithFrame:CGRectMake(37*PER_WIDTH, 160*PER_HEIGHT, SCREEN_WIDTH-74*PER_WIDTH, 350*PER_HEIGHT)];
    tipView.image=[UIImage imageNamed:@"img_jifen_pop"];
    tipView.userInteractionEnabled=YES;
    [blureyView addSubview:tipView];
    

    //删除按钮
    UIButton *guanbiBtn=[MyControl createButtonWithFrame:CGRectMake(tipView.width-33*PER_WIDTH, 10*PER_HEIGHT, 23*PER_WIDTH, 23*PER_WIDTH) ImageName:@"ico_guanbi" Target:self Action:@selector(guanbi) Title:@""];
    [tipView addSubview:guanbiBtn];
    
    
    UILabel * tipLb=[MyControl createLabelWithFrame:CGRectMake(0, 30*PER_HEIGHT, tipView.width, 16*PER_HEIGHT) Font:16 Text:@"恭喜您, 获取了5积分" Color:BLACK_COLOR];
    tipLb.textAlignment=NSTextAlignmentCenter;
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:tipLb.text];
    [attributedString setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                     TINK_COLOR, NSForegroundColorAttributeName,
                                     [UIFont fontWithName:HLT size:16*PER_WIDTH],NSFontAttributeName, nil]
                              range:NSMakeRange(8, 1)];
    
    tipLb.attributedText = attributedString;
    [tipView addSubview:tipLb];
    
    UILabel * sureLb=[MyControl createLabelWithFrame:CGRectMake(0, tipLb.bottom+10*PER_HEIGHT, tipView.width, 30*PER_HEIGHT) Font:13 Text:@"首次登陆此应用都可以获得5积分哦,如果完成课后小测可以获得更多积分" Color:FEELT_COLOR];
    sureLb.textAlignment=NSTextAlignmentCenter;
    
    [tipView addSubview:sureLb];
    
    //知道了按钮
    UIButton * cancelBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame=CGRectMake(55.5*PER_WIDTH, tipView.height-61*PER_HEIGHT, 190*PER_WIDTH, 36*PER_WIDTH);
    cancelBtn.layer.cornerRadius=cancelBtn.height/2;
    cancelBtn.backgroundColor=TINK_COLOR;
    cancelBtn.titleLabel.font=[UIFont fontWithName:HSGBW3 size:16];
    cancelBtn.titleLabel.font=[UIFont systemFontOfSize:16*PER_HEIGHT];
    [cancelBtn setTitle:@"知道了" forState:0];
    [cancelBtn setTitleColor:WHITE_COLOR forState:0];
    [cancelBtn addTarget:self action:@selector(cancelBtn) forControlEvents:UIControlEventTouchUpInside];
    [tipView addSubview:cancelBtn];
    
}
-(void)guanbi{
    [tipView removeFromSuperview];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
}
-(void)cancelBtn{
    [tipView removeFromSuperview];
    blureyView.hidden=YES;
    [self.view sendSubviewToBack:blureyView];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
